﻿using System;
using System.Text;
using System.Web;
using System.Reflection;
using System.Resources;

namespace WFBASE
{
    public class Post : IHttpHandler
    {
        /// <summary>
        /// 您必須在 Web 的 web.config 檔案中設定這個處理常式
        /// 並且向 IIS 註冊，然後才可以使用它。如需詳細資訊，
        /// </summary>
        #region IHttpHandler Members

        public void ProcessRequest(HttpContext context)
        {
            //String result;

            //String className = QueryValue("MothodName").Split('.')[0],    //類
            //       method = QueryValue("MothodName").Split('.')[1];       //方法

            //result = Invoke.GetInvoker().invoke(className, method);
            //context.Response.Write(result);
            String result;
            String methodName = QueryValue("MothodName");
            String className = methodName.Substring(0, methodName.LastIndexOf('.'));
            String method = methodName.Substring(methodName.LastIndexOf('.') + 1);
            result = Invoke.GetInvoker().invoke(className, method);
            context.Response.Write(result);
        }

        /// <summary>
        /// 通過KEY取得參數值
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public static string QueryValue(string key)
        {
            if (System.Web.HttpContext.Current.Request.Params[key] != null)
                return System.Web.HttpContext.Current.Request.Params[key];
            else
                return "";
        }

        public bool IsReusable
        {
            get { return true; }
        }
        #endregion
    }
}
